home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 1 / Cream of the Crop 1.iso / PROGRAM / DJEMU106.ARJ / E02.CC < prev    next >
C/C++ Source or Header  |  1991-04-25  |  1KB  |  74 lines

  1. #include "emu.h"
  2. #include "rmov.h"
  3. #include "compare.h"
  4.  
  5. void emu_02()
  6. {
  7.   if (empty())
  8.     return;
  9.   if (modrm > 0277)
  10.   {
  11.     // fcom st(i)
  12.     if (empty(modrm&7))
  13.     {
  14.       setcc(SW_C3|SW_C2|SW_C0);
  15.       return;
  16.     }
  17.     int c = compare(st(), st(modrm&7));
  18.     int f;
  19.     if (c & COMP_NAN)
  20.     {
  21.       exception(EX_I);
  22.       f = SW_C3 | SW_C2 | SW_C0;
  23.     }
  24.     else
  25.       switch (c)
  26.       {
  27.         case COMP_A_LT_B:
  28.           f = SW_C0;
  29.           break;
  30.         case COMP_A_EQ_B:
  31.           f = SW_C3;
  32.           break;
  33.         case COMP_A_GT_B:
  34.           f = 0;
  35.           break;
  36.         case COMP_NOCOMP:
  37.           f = SW_C3 | SW_C2 | SW_C0;
  38.           break;
  39.       }
  40.     setcc(f);
  41.     
  42.   }
  43.   else
  44.   {
  45.     // fcom m32real
  46.     reg t;
  47.     r_mov((float *)get_modrm(), t);
  48.     int c = compare(st(), t);
  49.     int f;
  50.     if (c & COMP_NAN)
  51.     {
  52.       exception(EX_I);
  53.       f = SW_C3 | SW_C2 | SW_C0;
  54.     }
  55.     else
  56.       switch (c)
  57.       {
  58.         case COMP_A_LT_B:
  59.           f = SW_C0;
  60.           break;
  61.         case COMP_A_EQ_B:
  62.           f = SW_C3;
  63.           break;
  64.         case COMP_A_GT_B:
  65.           f = 0;
  66.           break;
  67.         case COMP_NOCOMP:
  68.           f = SW_C3 | SW_C2 | SW_C0;
  69.           break;
  70.       }
  71.     setcc(f);
  72.   }
  73. }
  74.